package com.cyz.user.controller;

import com.cyz.common.dto.UserDto;
import com.cyz.user.dto.UserPasswordDto;
import com.cyz.user.userService.User_UserService;
import com.cyz.common.utils.R;
import com.cyz.common.validated.AddGroup;
import com.cyz.common.validated.UpdateGroup;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@Api(tags = "用户端用户相关接口")
@RestController
@RequestMapping("/user")
public class  UserController {

    @Autowired
    private User_UserService userUserService;

    @PostMapping("/toRegister")
    @ApiOperation(value = "用户端注册账号")
    public R toRegister(@Validated(AddGroup.class) @RequestBody UserDto userDto){
        return userUserService.toRegister(userDto);
    }

    @PostMapping("/toLogin")
    @ApiOperation(value = "用户端登录账号")
    public R toLogin(@Validated(AddGroup.class) @RequestBody UserDto userDto){
        return userUserService.login(userDto);
    }

    @PutMapping("/updateUser")
    @ApiOperation(value = "更新用户信息")
    public R updateUser(@Validated(UpdateGroup.class) @RequestBody UserDto userDto){
        return userUserService.updateUser(userDto);
    }

    @PutMapping("/updateUserPassword")
    @ApiOperation(value = "更新用户密码")
    public R updateUserPassword(@RequestBody UserPasswordDto userPasswordDto){
        return userUserService.updateUserPassword(userPasswordDto);
    }

    @ApiOperation(value = "退出登录")
    @GetMapping("/toLogout")
    public R toLogout(){
        return userUserService.logout();
    }


    @ApiOperation(value = "查询用户信息")
    @GetMapping("/queryUserMsg")
    public R queryUserMsg(){
        return userUserService.queryUserMsg();
    }
//    @ApiOperation(value = "查询收藏的免费课程")
//    @GetMapping("/queryMyShop")
//    public R queryMyCard(){
//        return userUserService.queryMyShop();
//    }
//
//
//    @ApiOperation(value = "增加付费课程")
//    @PostMapping("/addMyShop")
//    public R addMyShop(@Validated(AddGroup.class) @RequestBody ShopDto shopDto){
//        return userUserService.addMyShop(shopDto);
//    }
}
